package com.sdhs.myproject.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.myproject.domain.GcMyprojectContractInformation;
import com.sdhs.myproject.service.IGcMyprojectContractInformationService;


/**
 * 我的项目--项目合同信息Controller
 *
 * @author andong
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/myproject/contract")
public class GcMyprojectContractInformationController extends BaseController
{
    @Autowired
    private IGcMyprojectContractInformationService gcMyprojectContractInformationService;

    /**
     * 查询我的项目--项目合同信息列表
     */
    @PreAuthorize("@ss.hasPermi('myproject:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcMyprojectContractInformation gcMyprojectContractInformation)
    {
        startPage();
        List<GcMyprojectContractInformation> list = gcMyprojectContractInformationService.selectGcMyprojectContractInformationList(gcMyprojectContractInformation);
        return getDataTable(list);
    }

    /**
     * 导出我的项目--项目合同信息列表
     */
    @PreAuthorize("@ss.hasPermi('myproject:information:export')")
    @Log(title = "我的项目--项目合同信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcMyprojectContractInformation gcMyprojectContractInformation)
    {
        List<GcMyprojectContractInformation> list = gcMyprojectContractInformationService.selectGcMyprojectContractInformationList(gcMyprojectContractInformation);
        ExcelUtil<GcMyprojectContractInformation> util = new ExcelUtil<GcMyprojectContractInformation>(GcMyprojectContractInformation.class);
        util.exportExcel(response, list, "我的项目--项目合同信息数据");
    }

    /**
     * 获取我的项目--项目合同信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('myproject:information:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcMyprojectContractInformationService.selectGcMyprojectContractInformationById(id));
    }

    /**
     * 新增我的项目--项目合同信息
     */
    @PreAuthorize("@ss.hasPermi('myproject:information:add')")
    @Log(title = "我的项目--项目合同信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcMyprojectContractInformation gcMyprojectContractInformation)
    {
        return toAjax(gcMyprojectContractInformationService.insertGcMyprojectContractInformation(gcMyprojectContractInformation));
    }

    /**
     * 修改我的项目--项目合同信息
     */
    @PreAuthorize("@ss.hasPermi('myproject:information:edit')")
    @Log(title = "我的项目--项目合同信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcMyprojectContractInformation gcMyprojectContractInformation)
    {
        return toAjax(gcMyprojectContractInformationService.updateGcMyprojectContractInformation(gcMyprojectContractInformation));
    }

    /**
     * 删除我的项目--项目合同信息
     */
    @PreAuthorize("@ss.hasPermi('myproject:information:remove')")
    @Log(title = "我的项目--项目合同信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcMyprojectContractInformationService.deleteGcMyprojectContractInformationByIds(ids));
    }

    /**
     * 删除我的项目--项目合同信息
     */
    @PreAuthorize("@ss.hasPermi('myproject:information:remove')")
    @Log(title = "我的项目--项目合同信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/removeByProjectIdAndContractIds/{projectId}/{contractIds}")
    public AjaxResult removeByProjectIdAndContractIds(@PathVariable Long projectId, @PathVariable String[] contractIds)
    {
        return toAjax(gcMyprojectContractInformationService.deleteGcMyprojectContractInformationById(projectId, List.of(contractIds)));
    }

    /**
     * 项目看板合同数据
     */
    @GetMapping("/getAll/{ids}")
    public AjaxResult getAll(@PathVariable Long[] ids)
    {
         GcMyprojectContractInformation all = gcMyprojectContractInformationService.getAll(ids);
        return  success(all);
    }
}
